package com.example.edupublisher.mapper;

import com.example.edupublisher.bean.TradeProvinceFinalAmount;
import com.example.edupublisher.bean.TradeProvinceOrderCt;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * ClassName: TradeStatsMapper
 * Package: com.atguigu.edu.publisher.mapper
 * Description:
 *
 * @Author Mr.2
 * @Create 2023/9/12 10:44
 * @Version 1.0
 */
@Mapper
public interface TradeStatsMapper {
    // 1. 省份 下单数统计
    @Select("SELECT\n" +
            "  province_name,\n" +
            "  SUM(order_count) order_count\n" +
            "FROM dws_trade_province_order_window\n" +
            "PARTITION par#{date}\n" +
            "GROUP BY province_id, province_name;")
    List<TradeProvinceOrderCt> selectTradeProvinceOrderCt(@Param(value = "date") Integer date);

    // 2. 省份 下单金额统计
    @Select("SELECT\n" +
            "  province_name,\n" +
            "  SUM(final_amount) final_amount\n" +
            "FROM dws_trade_province_order_window\n" +
            "PARTITION par#{date}\n" +
            "GROUP BY province_id, province_name;\n")
    List<TradeProvinceFinalAmount> selectTradeProvinceFinalAmount(@Param(value = "date") Integer date);

    // 3. 省份 交易综合统计
    @Select("SELECT\n" +
            "  SUM(final_amount) final_amount\n" +
            "FROM dws_trade_province_order_window\n" +
            "PARTITION par#{date}")
    BigDecimal selectGMV(@Param(value = "date") Integer date);

}
